extends Node2D

@export var enemy_scenes: Array[PackedScene]
@export var spawn_interval: float = 5.0
@export var max_enemies: int = 10

func _ready():
    spawn_enemy()
    $SpawnTimer.start(spawn_interval)

func spawn_enemy():
    if get_child_count() >= max_enemies:
        return
        
    var random_enemy = enemy_scenes[randi() % enemy_scenes.size()]
    var enemy = random_enemy.instantiate()
    add_child(enemy)
    enemy.global_position = get_random_spawn_position()